﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using WMS.FC.Domain.PersistenceObject.Business;
using WMS.FC.Infrastructure.Common;

namespace WMS.FC.Infrastructure.POConfig.Business
{
    public class TechnologyProcessConfig : POBaseConfig<TechnologyProcessPO>
    {
        public override void InitializeData(EntityTypeBuilder<TechnologyProcessPO> builder)
        {
        }

        public override void MapColumn(EntityTypeBuilder<TechnologyProcessPO> builder, ref int index)
        {
            builder.HasComment("工艺工序表");
            builder.Property(entity => entity.Code).ConfigColumn("CODE", "编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.Name).ConfigColumn("NAME", "名称", 100, true).HasColumnOrder(index++);
            builder.Property(entity => entity.ZoneCode).ConfigColumn("ZONE_CODE", "区域编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.TypeCode).ConfigColumn("TYPE_CODE", "类型编码", 50, true).HasColumnOrder(index++);
            builder.Property(entity => entity.SortNumber).ConfigColumn("SORT_NUMBER", "排序").HasColumnOrder(index++);
            builder.Property(entity => entity.IsInbound).ConfigColumn("IS_INBOUND", "是否入库").HasColumnOrder(index++);
            builder.Property(entity => entity.IsNeedFakeCell).ConfigColumn("IS_NEED_FAKE_CELL", "是否需要假电池").HasColumnOrder(index++);
            builder.Property(entity => entity.WarehouseCode).ConfigColumn("WAREHOUSE_CODE", "仓库编码", 50, true).HasColumnOrder(index++);
        }

        public override void MapIndex(EntityTypeBuilder<TechnologyProcessPO> builder)
        {
            builder.HasIndex(entity => new { entity.Code, entity.WarehouseCode }).HasDatabaseName($"UN_{TableName}_1").IsUnique();
        }
    }
}
